﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AnswerAddListenter : MonoBehaviour
{
    private void Start()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            
            string answer = (i+1).ToString();
         
           // bool b=new bool();
            Toggle toggle = transform.GetChild(i).GetComponent<Toggle>();
            
            toggle.onValueChanged.AddListener(( b) => {

                if (toggle.group == null)
                {
                    if (toggle.isOn)
                    {
                        if (!AnswerSys.Instance.currentAnswer.Contains(answer))
                        {
                            AnswerSys.Instance.currentAnswer += answer;

                            AnswerSys.Instance.currentAnswer += "/";

                        }

                    }
                    else
                    {
                        AnswerSys.Instance.RemoveAnswer(answer);
                    }
                }
                else
                {
                    if (toggle.isOn)
                    {
                        if (!AnswerSys.Instance.currentAnswer.Contains(answer))
                        {
                            AnswerSys.Instance.currentAnswer = answer;
                            
                        }

                    }
                }
               

                
            });
            
        }
    }


  

}
